package com.example.module_hp_zao_yin_media.activity;

import android.Manifest;
import android.os.Build;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import com.example.module_hp_zao_yin_media.R;
import com.example.module_hp_zao_yin_media.base.BaseMvvmActivity;
import com.example.module_hp_zao_yin_media.base.BaseViewModel;
import com.example.module_hp_zao_yin_media.databinding.ActivityHpZaoYinPhotoInfoBinding;
import com.example.module_hp_zao_yin_media.util.DownBitmap;
import com.example.module_hp_zao_yin_media.util.Utils;
import com.fwlst.lib_base.utils.AdUtils;
import com.fwlst.lib_base.utils.JtXXPermissions;
import com.hjq.permissions.Permission;
import com.hjq.toast.Toaster;


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import kotlin.Unit;
import kotlin.jvm.functions.Function0;

public class HpZaoYinPhotoInfoActivity extends BaseMvvmActivity<ActivityHpZaoYinPhotoInfoBinding, BaseViewModel> {
    @Override
    protected int initLayout() {
        return R.layout.activity_hp_zao_yin_photo_info;
    }

    @Override
    protected int initBR() {
        return 0;
    }

    @Override
    protected void initView() {
        //banner广告
        AdUtils.INSTANCE.loadBannerAd(this,binding.bannerContainer);
        binding.hpZaoYinPhotoIv.setImageBitmap(Utils.PHOTO_BM);
        //点击事件-返回
        binding.hpZaoYinPhotoBt1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        //点击事件-保存
        binding.hpZaoYinPhotoBt3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getPermission();
            }
        });
    }
    private void getPermission(){
        JtXXPermissions.INSTANCE.requestGallery(this, new Function0<Unit>() {
            @Override
            public Unit invoke() {
                try {
                    DownBitmap.saveBitmap2File(mContext,Utils.PHOTO_BM,null,"");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                return null;
            }
        });
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        AdUtils.INSTANCE.destroyBannerAd();
    }
}